﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ebook.Data.Abstract
{
    public interface IRepository<T> where T:class
    {

        /// <summary>
        /// 获得该表 
        /// </summary>
        IQueryable<T> Table { get; }

  /// <summary>
        /// 通过id来获取实体对象
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>实体对象</returns>
        T GetById(int id);

        /// <summary>
        /// 插入实体对象
        /// </summary>
        /// <param name="entity">实体对象</param>
        void Insert(T entity);

        /// <summary>
        /// 插入实体对象的集合
        /// </summary>
        /// <param name="entities">实体对象集合</param>
        void Insert(IEnumerable<T> entities);

        /// <summary>
        /// 更新实体对象
        /// </summary>
        /// <param name="entity">实体对象</param>
        void Update(T entity);

        /// <summary>
        /// 更新实体对象集合
        /// </summary>
        /// <param name="entities">实体对象集合</param>
        void Update(IEnumerable<T> entities);

        /// <summary>
        /// 删除实体对象
        /// </summary>
        /// <param name="entity">删除实体对象</param>
        void Delete(T entity);

        /// <summary>
        /// 删除实体对象集合
        /// </summary>
        /// <param name="entities">实体对象的集合</param>
        void Delete(IEnumerable<T> entities);


        
    }
}
